using System;
using System.Collections.Generic;
using System.Text;
using System.IO;


namespace ReportUtility
{
    class FileHelper
    {
        public static IList<string[]> parse(string path, int[] start, int[] len){
            IList<string[]> list = new List<String[]>();

            Encoding encoding = Encoding.GetEncoding("gbk");
            StreamReader reader = new StreamReader(path, encoding);
            string line = null;

            int limit = start[start.Length-1] + len[len.Length-1];

            while ((line = reader.ReadLine()) != null)
            {
                byte[] byteArr = encoding.GetBytes(line); 
                if (byteArr.Length < limit)
                    continue;

                string[] segs = new string[start.Length];
                for (int i = 0; i < segs.Length; i++)
                {
                    //segs[i] = line.Substring(start[i], len[i]);
                    segs[i] = encoding.GetString(byteArr, start[i], len[i]);
                }

                list.Add(segs);
            }

            reader.Close();

            return list;
        }
    }
}
